package com.tianyu.leyou.controller;

import com.tianyu.leyou.model.UserBean;
import com.tianyu.leyou.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    IUserService userService;

    public Object list(Integer page, UserBean u) {
        u.setUsername("");
        Page<UserBean> page1 = userService.list(page, 5, u);
        for (UserBean userBean : page1.getContent()) {

        }
        return null;
    }

    @RequestMapping("/add")
    public Object add(UserBean userBean){
        userService.add(userBean);
        return "成功";
    }

    @RequestMapping("/delete")
    public Object delete(Integer id) {
        userService.delete(id);
        return "成功";
        //iter
    }

    @RequestMapping("/update")
    public Object update(Integer id,UserBean userBean) {
        userService.update(id,userBean);
        return "成功";
    }

}
